/*************************************************************************
> File Name: 01_test.cpp
> Author: hzy
> Created Time: 2023-08-14 11:26:36
> Description: 计算类的大小
************************************************************************/
#include <iostream>

using namespace std;

// 基类
class Father
{
public:
    void public_show()
    {
        cout << "Father:public_show()" << endl;
    }

protected:
    void protected_show()
    {
        cout << "Father:protected_show()" << endl;
    }

private:
    void private_show()
    {
        cout << "Father:private_show()" << endl;
    }
protected:
    //给派生类提供一个访问基类私有成员的接口
    void getPrivate_show()
    {
        private_show();
    }    
};

class Son1 : protected Father
{
public:
    void public_show()
    {
        cout << "Son1:public_show()" << endl;
    }

protected:
    void protected_show()
    {
        cout << "Son1:protected_show()" << endl;
    }

private:
    void private_show()
    {
        cout << "Son1:private_show()" << endl;
    }
public:
    void func()
    {
        Father::public_show();
        Father::protected_show();
        getPrivate_show();
    }
};

class GrandSon1 : public Son1
{
public:
    void Test()
    {
        Father::protected_show();
        Son1::protected_show();
        protected_show();       //就近原则,默认访问Son1的成员函数
    }
};

void test01()
{
    Son1 s1;
    s1.func();
}
void test02()
{
    GrandSon1 gs1;

    gs1.Test();
}

int main()
{
    test01();
    test02();

    return 0;
}